package com.itheima.string;

import java.util.Scanner;
import java.util.concurrent.BrokenBarrierException;

//完成登录案例
public class StringTest4 {
    public static void main(String[] args) {

        for (int i = 0; i < 3; i++) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入用户名:");
            String username = sc.next();
            System.out.println("请输入密码:");
            String password = sc.next();

            boolean flag = login(username, password);
            if(flag){
                System.out.println("登录成功");
                break;
            }else {
                System.out.println("登录失败");
            }
        }


    }
    public static boolean login(String username, String password) {
        String okusername = "admin";
        String okpassword = "123456";
        /*if(username.equals(okusername) && password.equals(okpassword)){
            return true;
        }else{
            return false;
        }*/

        return username.equals(okusername) && password.equals(okpassword);
    }
}
